#!/bin/bash
 # PLA: Prediction Length Awareness
#!/bin/bash

export CUDA_VISIBLE_DEVICES=0
model_name=iTransformerCNN_PLA

# === 通用参数设置 ===
common_params="--task_name long_term_forecast \
  --is_training 1 \
  --model $model_name \
  --features M \
  --seq_len 96 \
  --label_len 48 \
  --e_layers 2 \
  --d_layers 1 \
  --factor 3 \
  --d_model 128 \
  --d_ff 128 \
  --des 'iTransformerCNNExp' \
  --itr 3 \
  --fusion_type gate \
  --cnn_kernel_sizes 3,5,7 \
  --use_dilated_cnn"

# === 基于 ETTh1 的预测长度实验 ===
echo "## Prediction Length Experiment on ETTh1 ##"
pred_lengths=(1 3 6 9 12 48 96 144 336 720)

for pred_len in "${pred_lengths[@]}"; do
  model_id="ETTh1_${model_name}_96_${pred_len}"
  echo "Running ETTh1 experiment with pred_len: $pred_len"
  python -u run.py $common_params \
    --root_path ./dataset/ETT-small/ \
    --data_path ETTh1.csv \
    --data ETTh1 \
    --enc_in 7 --dec_in 7 --c_out 7 \
    --model_id $model_id \
    --pred_len $pred_len
done

# === 多数据集实验 ===
echo "## Cross-Dataset Experiment ##"
datasets=("ETTh2" "ETTm1" "ETTm2" "electricity" "weather")
pred_len_selected=(96 192 336 720)

for dataset in "${datasets[@]}"; do
  if [[ "$dataset" == "ETTh2" ]]; then
    root_path="./dataset/ETT-small/"
    data_path="ETTh2.csv"
    enc_in=7; dec_in=7; c_out=7
  elif [[ "$dataset" == "ETTm1" ]]; then
    root_path="./dataset/ETT-small/"
    data_path="ETTm1.csv"
    enc_in=7; dec_in=7; c_out=7
  elif [[ "$dataset" == "ETTm2" ]]; then
    root_path="./dataset/ETT-small/"
    data_path="ETTm2.csv"
    enc_in=7; dec_in=7; c_out=7
  elif [[ "$dataset" == "electricity" ]]; then
    root_path="./dataset/electricity/"
    data_path="electricity.csv"
    enc_in=321; dec_in=321; c_out=321
  elif [[ "$dataset" == "weather" ]]; then
    root_path="./dataset/weather/"
    data_path="weather.csv"
    enc_in=21; dec_in=21; c_out=21
  fi

  for pred_len in "${pred_len_selected[@]}"; do
    model_id="${dataset}_${model_name}_96_${pred_len}"
    echo "Running ${dataset} with pred_len: $pred_len"
    python -u run.py $common_params \
      --root_path $root_path \
      --data_path $data_path \
      --data $dataset \
      --enc_in $enc_in --dec_in $dec_in --c_out $c_out \
      --model_id $model_id \
      --pred_len $pred_len
  done
done

# === 消融实验1：不同CNN卷积核配置 ===
echo "## Ablation Study: CNN Kernel Sizes ##"
kernel_configs=("single" "dual" "triple" "quad")
kernel_args=("3" "3,5" "3,5,7" "3,5,7,11")

for i in {0..3}; do
  config=${kernel_configs[i]}
  kernels=${kernel_args[i]}
  model_id="ETTh1_${model_name}_kernel_${config}"
  echo "Running ablation on CNN kernels: ${kernels}"
  python -u run.py $common_params \
    --root_path ./dataset/ETT-small/ \
    --data_path ETTh1.csv \
    --data ETTh1 \
    --enc_in 7 --dec_in 7 --c_out 7 \
    --model_id $model_id \
    --pred_len 96 \
    --cnn_kernel_sizes $kernels
done

# === 消融实验2：融合模块方式 ===
echo "## Ablation Study: Fusion Strategies ##"
fusion_types=("gate" "concat" "attention")

for fusion in "${fusion_types[@]}"; do
  model_id="ETTh1_${model_name}_fusion_${fusion}"
  echo "Running ablation on fusion_type: ${fusion}"
  python -u run.py $common_params \
    --root_path ./dataset/ETT-small/ \
    --data_path ETTh1.csv \
    --data ETTh1 \
    --enc_in 7 --dec_in 7 --c_out 7 \
    --model_id $model_id \
    --pred_len 96 \
    --fusion_type $fusion
done

# === 复现性测试：不同随机种子 ===
echo "## Reproducibility Test: Random Seeds ##"
seeds=(42 43 44 45 46)

for seed in "${seeds[@]}"; do
  model_id="ETTh1_${model_name}_seed_${seed}"
  echo "Running reproducibility test with seed: $seed"
  python -u run.py $common_params \
    --root_path ./dataset/ETT-small/ \
    --data_path ETTh1.csv \
    --data ETTh1 \
    --enc_in 7 --dec_in 7 --c_out 7 \
    --model_id $model_id \
    --pred_len 96 \
    --seed $seed
done

echo "=== All Experiments Completed Successfully ==="
